//
//  ImageCell.m
//  cascade-realm
//
//  Created by QSC on 1/6/24.
//

#import "ImageCell.h"

@implementation ImageCell
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {

        self.contentView.backgroundColor = Hex(0xF6F8FA);
        
        UIImageView *imagev = [[UIImageView alloc]initWithFrame:self.bounds];
        _imageV = imagev;
        _imageV.contentMode = UIViewContentModeScaleToFill;
      
        
        _imageV.clipsToBounds = YES;

        [self.contentView addSubview:imagev];
        
        [_imageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        
        UIButton * delBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [delBtn setImage:Img(@"remove") forState:UIControlStateNormal];
        [self.contentView addSubview:delBtn];
        [delBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.top.equalTo(self.contentView).inset(3);
            make.size.mas_equalTo(20);
        }];
        delBtn.hidden = YES;
        [delBtn addTarget:self action:@selector(delClick) forControlEvents:UIControlEventTouchUpInside];
        self.deleteBtn = delBtn;
        
        
        UIImageView * centerImg = [[UIImageView alloc] initWithImage:Img(@"photo")];
        [self.contentView addSubview:centerImg];
        self.centerImgv = centerImg;
        [centerImg mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(self.contentView);
        }];
        centerImg.hidden = YES;
        
        
    }
    return self;
}


- (void)delClick{
    
    !self.deleteBlock?:self.deleteBlock();
}
@end
